Skip to content

Conversation

@denrase
Copy link
Collaborator

@denrase denrase commented Sep 25, 2025

📜 Description

The Sentry swift-log integration.

Setup

  • Adds SentrySwiftLog as a target to Sentry target
  • Adds SentrySwiftLog to Package.swift
  • Add a sample call to the iOS15-SwiftUi app so you can play around with it

Implementation

  • Adds SentryLogHandler
  • sentry-log metadata is mapped to attributes and prefixed with swift-log
  • Other parameters of the log function are set as attributes and

Discussion

Here vs Own Repo

Added the integration to this repo, because it is easier for us to maintain.

On the swift-log repo integrations section is linking to the swift package index with search term swift-log. So for visibility, we'd need to have a separate swift-log-sentry repo.

https://github.com/apple/swift-log?tab=readme-ov-file#available-log-handler-backends
https://swiftpackageindex.com/search?query=swift-log

Distribution

Only distributed through SPM, as swift-log dropped support for CocoaPods. Also, we'll not be able to distribute this as a binary, as swift-log is not supporting that.

Module was not compiled with library evolution support; using it means binary compatibility for can't be guaranteed

💡 Motivation and Context

Closes #5372

💚 How did you test it?

Unit Tests
Sample App

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@codecov
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.186%. Comparing base (1655116) to head (3c15f44).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6286       +/-   ##
=============================================
+ Coverage   85.169%   85.186%   +0.016%     
=============================================
  Files          452       453        +1     
  Lines        27659     27704       +45     
  Branches     12117     12119        +2     
=============================================
+ Hits         23557     23600       +43     
- Misses        4054      4059        +5     
+ Partials        48        45        -3     
Files with missing lines Coverage Δ
SentryTestUtils/Sources/ClearTestState.swift 86.000% <100.000%> (+0.583%) ⬆️
Sources/SentrySwiftLog/SentryLogHandler.swift 100.000% <100.000%> (ø)

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1655116...3c15f44. Read the comment docs.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 25, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1224.15 ms 1255.88 ms 31.73 ms
Size 23.75 KiB 1023.84 KiB 1000.09 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4a7a005 1229.15 ms 1243.35 ms 14.20 ms
ae7be93 1236.24 ms 1258.18 ms 21.94 ms
b9ceffb 1222.57 ms 1247.96 ms 25.39 ms
884b224 1221.11 ms 1255.88 ms 34.77 ms
2a9a505 1221.49 ms 1238.49 ms 17.00 ms
00d9740 1223.53 ms 1249.75 ms 26.22 ms
e8f9a1d 1229.02 ms 1264.17 ms 35.15 ms
6502818 1229.08 ms 1245.46 ms 16.37 ms
5712478 1220.10 ms 1239.69 ms 19.59 ms
8da82b4 1220.08 ms 1248.24 ms 28.16 ms

App size

Revision Plain With Sentry Diff
4a7a005 23.75 KiB 979.96 KiB 956.22 KiB
ae7be93 23.75 KiB 879.24 KiB 855.49 KiB
b9ceffb 23.75 KiB 969.07 KiB 945.32 KiB
884b224 23.75 KiB 879.55 KiB 855.80 KiB
2a9a505 23.75 KiB 874.46 KiB 850.71 KiB
00d9740 23.75 KiB 938.32 KiB 914.57 KiB
e8f9a1d 23.75 KiB 969.78 KiB 946.04 KiB
6502818 23.75 KiB 959.45 KiB 935.70 KiB
5712478 23.75 KiB 969.28 KiB 945.54 KiB
8da82b4 23.75 KiB 913.63 KiB 889.88 KiB

Previous results on branch: denrase/swift-log-sentry-poc

Startup times

Revision Plain With Sentry Diff
f23a1b4 1226.17 ms 1264.55 ms 38.38 ms
94f5fa8 1222.72 ms 1254.48 ms 31.75 ms
0fd08ab 1225.14 ms 1256.49 ms 31.35 ms
b52b178 1227.86 ms 1255.65 ms 27.79 ms
2bd1339 1223.22 ms 1248.85 ms 25.64 ms
74acaca 1209.85 ms 1247.02 ms 37.17 ms
47c3aeb 1221.08 ms 1259.42 ms 38.34 ms
6245148 1229.77 ms 1269.93 ms 40.17 ms
53379e0 1231.19 ms 1269.38 ms 38.20 ms

App size

Revision Plain With Sentry Diff
f23a1b4 23.75 KiB 1.01 MiB 1016.14 KiB
94f5fa8 23.75 KiB 1023.29 KiB 999.54 KiB
0fd08ab 23.75 KiB 995.43 KiB 971.68 KiB
b52b178 23.75 KiB 989.97 KiB 966.22 KiB
2bd1339 23.75 KiB 1.01 MiB 1006.48 KiB
74acaca 23.75 KiB 1023.82 KiB 1000.07 KiB
47c3aeb 23.75 KiB 1023.84 KiB 1000.09 KiB
6245148 23.75 KiB 1023.82 KiB 1000.07 KiB
53379e0 23.75 KiB 1.00 MiB 1002.40 KiB

@denrase denrase changed the title Structured Logs: swift-log Integration Structured Logs: Add SentrySwiftLog Integration Sep 30, 2025
@denrase denrase marked this pull request as ready for review October 1, 2025 13:25
cursor[bot]

This comment was marked as outdated.

Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@denrase
Copy link
Collaborator Author

denrase commented Nov 5, 2025

@itaybre @philprime Thank you both for your feedback. I will merge once CI is happy (excluding timeouts) and then rebase the other draft PRs for the other integrations, using the same setup we have here. 🙇‍♂️

@denrase denrase enabled auto-merge (squash) November 5, 2025 12:06
@denrase denrase merged commit 8bccc72 into main Nov 5, 2025
200 of 207 checks passed
@denrase denrase deleted the denrase/swift-log-sentry-poc branch November 5, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log Integration: swift-log

4 participants